// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
      if (cordova.platformId === 'ios' && window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        cordova.plugins.Keyboard.disableScroll(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider) {

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider

  // setup an abstract state for the tabs directive
    .state('tab', {
    url: '/tab',
    abstract: true,
    templateUrl: 'templates/tabs.html',
     controller: 'tabCtrl'
  })

  // Each tab has its own nav history stack:

  
     .state('tab.product', {
         url: '/product/:productId',
        //   cache:'false', 
         views: {
             'tab-product_list': {
                 templateUrl: 'templates/product_detail.html',
                 controller: 'productCtrl'
             }
         }
     })
  .state('tab.product_list', {
      url: '/product_list',
    //    cache:'false', 
      views: {
          'tab-product_list': {
              cache:'false', 
              templateUrl: 'templates/product_list.html',
              controller: 'product_listCtrl'
          }
      }
  })
    .state('tab.shoppingcart', {
        url: '/shoppingcart',
         cache:'false', 
        views: {
            'tab-shoppingcart': {
                templateUrl: 'templates/shoppingcart.html',
                controller: 'shoppingcartCtrl'
            }
        }
    })
    .state('tab.order_management', {
        url: '/order_management',
         cache:'false', 
        views: {
            'tab-order_management': {
                templateUrl: 'templates/order_management.html',
                controller: 'order_managementCtrl'
            }
        }
    })
    .state('tab.person_center', {
        url: '/person_center',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/person_center.html',
                controller: 'person_centerCtrl'
            }
        }
    })
    .state('tab.sign_in', {
        url: '/person_center/sign_in',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/sign_in.html',
                controller: 'sign_inCtrl'
            }
        }
    })
    .state('tab.sign_out', {
        url: '/person_center/sign_out',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/sign_out.html',
                controller: 'sign_outCtrl'
            }
        }
    })
    .state('tab.person_information', {
        url: '/person_center/person_information',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/person_information.html',
                controller: 'person_informationCtrl'
            }
        }
    })
    .state('tab.seller_management', {
        url: '/person_center/seller_management',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/seller_management.html',
                controller: 'seller_managementCtrl'
            }
        }
    })
    .state('tab.seller_product', {
        url: '/person_center/seller_management/seller_product',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/seller_product.html',
                controller: 'seller_productCtrl'
            }
        }
    })
     .state('tab.seller_order', {
        url: '/person_center/seller_management/seller_order',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/seller_order.html',
                controller: 'seller_orderCtrl'
            }
        }
    })
    .state('tab.seller_product_add', {
        url: '/person_center/seller_management/seller_product_add',
         cache:'false', 
        views: {
            'tab-person_center': {
                templateUrl: 'templates/seller_product_add.html',
                controller: 'seller_product_addCtrl'
            }
        }
    })
    .state('tab.order_all', {
        url: '/order_management/order_all',
         cache:'false', 
        views: {
            'tab-order_management': {
                templateUrl: 'templates/order_all.html',
                controller: 'order_allCtrl'
            }
        }
    })
    .state('tab.order_completed', {
        url: '/order_management/order_completed',
         cache:'false', 
        views: {
            'tab-order_management': {
                templateUrl: 'templates/order_completed.html',
                controller: 'order_completedCtrl'
            }
        }
    })
    .state('tab.order_in_progress', {
        url: '/order_management/order_in_progress',
         cache:'false', 
        views: {
            'tab-order_management': {
                templateUrl: 'templates/order_in_progress.html',
                controller: 'order_in_progressCtrl'
            }
        }
    });

  $urlRouterProvider.otherwise('/tab/product_list');

});
